import java.io.*;

public final class c
{

    public static final ck a = new ck(177);

    public c()
    {
    }

    public static void a(DataOutputStream dataoutputstream, cj cj1) throws IOException {
        dataoutputstream.writeByte((byte)cj1.a());
        cj1.a(dataoutputstream, new ax());
        dataoutputstream.writeByte(255);
    }

    public static cj a(DataInputStream datainputstream) throws IOException {
        cj cj1 = null;
        int i = datainputstream.readUnsignedByte();
        switch(i)
        {
        case 172: 
            cj1 = new cb();
            break;

        case 29: // '\035'
            cj1 = new bq();
            break;

        case 173: 
            cj1 = new p();
            break;

        case 27: // '\033'
        	cj1 = new ck(27);
            break;

        case 177: 
        	cj1 = a;
            break;

        case 192: 
        	cj1 = new ag();
            break;

        default:
            throw new IOException("Invalid message tag: " + Integer.toString(i, 16));
        }
        int j;
        while ((j = datainputstream.readUnsignedByte()) != 255) {
        	int k = 0;
        	switch (j & 0xc0) {
        	case 0:
        		break;
        	case 64:
        		k = datainputstream.readUnsignedByte();
        		break;
        	case 128:
        		k = datainputstream.readUnsignedShort();
        		break;
        	case 192:
        		k = datainputstream.readInt();
        		break;
        	}
        	cj1.a(datainputstream, j & 0x3f, k);
        }
        return cj1;
    }

    public static final String a(byte abyte0[])
    {
        if(abyte0.length == 0)
            return "";
        DataInputStream datainputstream;
        try {
        	datainputstream = new DataInputStream(new ByteArrayInputStream(abyte0));
        	return a(((DataInput) datainputstream));
        } catch (IOException ioe) {
            return "";
        }
    }

    public static final byte[] a(String s)
    {
        ByteArrayOutputStream bytearrayoutputstream;
        try{
        bytearrayoutputstream = new ByteArrayOutputStream();
        DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
        a(dataoutputstream, s);
        return bytearrayoutputstream.toByteArray();
        }catch(Exception ex){}
        return null;
    }

    private static void d(DataOutput dataoutput, String s) throws IOException {
        int i = s.length();
        for(int j = 0; j < i; j++)
        {
            char c1;
            if((c1 = s.charAt(j)) >= '\377')
            {
                dataoutput.writeByte(255);
                dataoutput.writeChar(c1);
            } else
            {
                dataoutput.writeByte((byte)c1);
            }
        }

    }

    private static String a(DataInput datainput, int i) throws IOException {
        StringBuffer stringbuffer = new StringBuffer(i);
        for(int j = 0; j < i; j++)
        {
            int k;
            if((k = datainput.readUnsignedByte()) == 255)
                stringbuffer.append(datainput.readChar());
            else
                stringbuffer.append((char)k);
        }

        return stringbuffer.toString();
    }

    public static void a(DataOutput dataoutput, String s) throws IOException {
        int i;
        if((i = s.length()) > 255)
            i = 255;
        dataoutput.writeByte(i);
        d(dataoutput, s);
    }

    public static String a(DataInput datainput) throws IOException
    {
        int i;
        if((i = datainput.readUnsignedByte()) == 0)
            return "";
        else
            return a(datainput, i);
    }

    public static void b(DataOutput dataoutput, String s) throws IOException {
        int i;
        if((i = s.length()) > 65535)
            i = 65535;
        dataoutput.writeShort(i);
        d(dataoutput, s);
    }

    public static String b(DataInput datainput) throws IOException {
        int i;
        if((i = datainput.readUnsignedShort()) == 0)
            return "";
        else
            return a(datainput, i);
    }

    public static void c(DataOutput dataoutput, String s) throws IOException {
        int i = s.length();
        dataoutput.writeInt(i);
        d(dataoutput, s);
    }

    public static String c(DataInput datainput) throws IOException {
        int i;
        if((i = datainput.readInt()) < 0)
            throw new EOFException();
        if(i == 0)
            return "";
        else
            return a(datainput, i);
    }

    public static ac d(DataInput datainput) throws IOException {
        return new ac(a(datainput), datainput.readLong());
    }

    public static void a(DataOutput dataoutput, ac ac1) throws IOException {
        a(dataoutput, ac1.b);
        dataoutput.writeLong(ac1.a);
    }

}